<template>
  <div class="pos-rlt wfull">
    <a-input
      type="textarea"
      :rows="rows"
      :style="{width:width>0?`${width}px`:'100%'}"
      v-model.trim="val"
      :placeholder="placeholder"
      :disabled="disabled"
      :maxLength="maxLength">
    </a-input>
    <div class="pos-abs r0 fs10" style="bottom:-20px">{{ val.length }}/{{ maxLength }}</div>
  </div>
</template>

<script>
export default {
  model: {
    prop: 'modelVal',
    event: 'change'
  },
  props: {
    modelVal: {
      type: String,
      default: ''
    },
    width: {
      type: Number,
      default: 0
    },
    placeholder: {
      type: String,
      default: '请输入内容'
    },
    disabled: {
      type: Boolean,
      default: false
    },
    rows: {
      type: Number,
      default: 4
    },
    maxLength: {
      type: Number,
      default: 50
    }
  },
  data () {
    return {
      val: ''
    }
  },
  mounted () {
    this.val = this.modelVal || ''
  },
  watch: {
    modelVal (v) {
      this.val = v || ''
    },
    val (v) {
      this.$emit('change', v)
    }
  },
  methods: {
  }
}
</script>
<style lang="scss" scoped>
</style>
